<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

class HTML_bpnews
{
	function editNews( $row, $lists, $option )
	{
		$editor =& JFactory::getEditor();
		JHTML::_('behavior.calendar');
		?>
		<form action = "index.php" method = "post" name = "adminForm" id = "adminForm">
			<fieldset class = "adminForm">
				<legend>Details</legend>
				<table class = "admintable">
					<tr>
						<td width = "100" align = "right" class = "key">
							Title:
						</td>
						<td>
							<input class = "text_area" type = "text" name = "title" id = "title" size = "50"
								value = "<?php echo $row->title; ?>" />
						</td>
					</tr>
					<tr>
						<td width = "100" align = "right" class = "key">
							Text:
						</td>
						<td>
							<?php echo $editor->display( 'text', $row->text, '100%', '150', '40', '5' ); ?>
						</td>
					</tr>
					<tr>
						<td width = "100" align = "right" class = "key">
							Date:
						</td>
						<td>
							<input class = "inputbox" type = "text" name = "created" id = "created" 
								size = "25" maxlength = "19" value = "<?php echo $row->created; ?>" />
							<input type = "reset" class = "button" value = "..."
								onclick = "return showCalendar('created', 'y-mm-dd');" />
						</td>
					</tr>
					<tr>
						<td width = "100" align = "right" class = "key">
							Published:
						</td>
						<td>
							<?php echo $lists['published']; ?>
						</td>
					</tr>
				</table>
			</fieldset>
			<input type = "hidden" name = "id" value = "<?php echo $row->id; ?>" />
			<input type = "hidden" name = "option" value = "<?php echo $option; ?>" />
			<input type = "hidden" name = "task" value = "" />
		</form>

<?php
	}
	
	function showNews( $option, &$rows )
	{
		?>
		<form action = "index.php" method = "post" name = "adminForm">
		<table class = "adminlist">
			<thead>
				<tr>
					<th width = "20">
						<input type = "checkbox" name = "toggle" value = ""
							onclick = "checkAll(<?php echo count( $rows ); ?>)" />
					</th>
					<th class = "title">Title</th>
					<th width = "15%">Text</th>
					<th width = "10%">Created</th>
					<th width = "5%" nowrap = "nowrap">Published</th>
				</tr>
			</thead>
			<?php
			jimport('joomla.filter.output');
			$k = 0;
			for( $i = 0, $n = count( $rows ); $i < $n; $i++ )
			{
				$row = &$rows[$i];
				$checked = JHTML::_('grid.id', $i, $row->id );
				$published = JHTML::_('grid.published', $row, $i);
				$link = JFilterOutput::ampReplace( 'index.php?option='.$option.'&task=edit&cid[]='.$row->id );
				$words = explode( ' ', $row->text );
				$words = implode( ' ', array_slice( $words, 0, 10 ) );
			 ?>
			<tr class = "<?php echo "row$k"; ?>">
				<td>
					<?php echo $checked; ?>
				</td>
				<td>
					<a href = "<?php echo $link; ?>">
						<?php echo $row->title; ?>
					</a>
				</td>
				<td>
					<?php echo $words . '...'; ?>
				</td>
				<td>
					<?php echo $row->created; ?>
				</td>
				<td align = "center">
					<?php echo $published; ?>
				</td>
			</tr>
			<?php
			$k = 1 - $k; 
			}
			?>
		</table>
		<input type = "hidden" name = "option" value = "<?php echo $option; ?>" />
		<input type = "hidden" name = "task" value = "" />
		<input type = "hidden" name = "boxchecked" value = "0" />
		</form>
		<?php 
	}
}
?>